package crivia.eca.am2.carry;

import java.util.List;

import crivia.c.a.KeyLink;
import crivia.c.carry.SubCarry;
import crivia.c.carry.ValueField;
import crivia.c.exception.CarryIOFail;
import crivia.eca.ECA;
import crivia.ecp.a.ECC;
import crivia.ecp.common.ECR;
import crivia.src.CI;

public class WorkflowModelField extends ECC {
	
	static {
		
		if (! createTable(WorkflowModelField.class, true)){
			throw new CarryIOFail("Data Base Table Create Fail.");
		}
		
	}
	
	public static void main(String[] args) {
		CI.refreshDBI(WorkflowModelField.class);
		CI.refreshFields(WorkflowModelField.class);
	}

	@Override
	public String tableName() {
		return "Crivia_AM2_WMField";
	}

	@Override
	public void keyLinks(List<KeyLink> keyLinks) {
		keyLinks.add(SubCarry.c2d("wm", WorkflowModel.class));
		keyLinks.add(ValueField.c2d("showOrder",int.class));
		keyLinks.add(ValueField.c2d("tableIndex",int.class));
		keyLinks.add(ValueField.c2d("tableName"));
		keyLinks.add(ValueField.c2d("key","key_"));
		keyLinks.add(ValueField.c2d("name"));
		keyLinks.add(ValueField.c2d("remark"));
	}


	
	
	
	//XXX DBI Begin.
	public enum Keys{
		wm("wm","wm")
		,showOrder("showOrder","showOrder")
		,tableIndex("tableIndex","tableIndex")
		,tableName("tableName","tableName")
		,key("key","key_")
		,name("name","name")
		,remark("remark","remark")
		;
		private String _dbKey;
		private String _key;
		Keys(String key,String dbKey){_key=key;_dbKey=dbKey;}
		@Override
		public String toString(){return _dbKey;}
		/**  <b>Key</b> in <b>Carry</b>. */
		public String key(){return _key;}
	}
	private static crivia.eca.am2.carry.WorkflowModelField dbi;
	public synchronized static void initDBI(){if(null!=dbi)return;dbi=new crivia.eca.am2.carry.WorkflowModelField();}
	/**  <b>DB Table</b> of <b>Carry</b>. */
	public static String table(){initDBI();return dbi.tableName();}
	/**  <b>Primary Key</b> of <b>Carry</b>. */
	public static String pk(){initDBI();return dbi.pk4db();}
	/**  <b>Relation SQL</b> of <b>Relation Key</b>. */
	public static String rSQL(crivia.eca.am2.carry.WorkflowModelField.Keys k,String t){initDBI();return dbi.relationSQL(k.key(),t);}
	//XXX DBI End.



	

	

	

	// XXX Fields Begin.



	/** ...(Miss Tip Text.) */
	private java.lang.String id;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getId(){
		return id;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setId(java.lang.String id){
		this.id = id;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private crivia.eca.am2.carry.WorkflowModel wm;
	/** Getter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModel getWm(){
		if (null == wm){
			wm = new crivia.eca.am2.carry.WorkflowModel();
		}
		return wm;
	}


	/** ...(Miss Tip Text.) */
	private int showOrder;
	/** Getter for ...(Miss Tip Text.) */
	public int getShowOrder(){
		return showOrder;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setShowOrder(int showOrder){
		this.showOrder = showOrder;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private int tableIndex;
	/** Getter for ...(Miss Tip Text.) */
	public int getTableIndex(){
		return tableIndex;
	}


	/** ...(Miss Tip Text.) */
	private java.lang.String tableName;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getTableName(){
		return tableName;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setTableName(java.lang.String tableName){
		this.tableName = tableName;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private java.lang.String key;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getKey(){
		return key;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setKey(java.lang.String key){
		this.key = key;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private java.lang.String name;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getName(){
		return name;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setName(java.lang.String name){
		this.name = name;
		return this;
	}


	/** ...(Miss Tip Text.) */
	private java.lang.String remark;
	/** Getter for ...(Miss Tip Text.) */
	public java.lang.String getRemark(){
		return remark;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setRemark(java.lang.String remark){
		this.remark = remark;
		return this;
	}


	// XXX Fields End.
	

	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setTableIndex(int tableIndex){
		this.tableIndex = tableIndex;
		if (null != wm && ECR.hasCondition(wm.getWorkflowID())){
			tableName = ECA.getRequestTableName(wm.getWorkflowID(), tableIndex);
		}
		return this;
	}
	/** Setter for ...(Miss Tip Text.) */
	public crivia.eca.am2.carry.WorkflowModelField setWm(crivia.eca.am2.carry.WorkflowModel wm){
		this.wm = wm;
		if (null != wm && ECR.hasCondition(wm.getWorkflowID())){
			tableName = ECA.getRequestTableName(wm.getWorkflowID(), tableIndex);
		}
		return this;
	}
	

}